import java.util.Arrays;
import java.util.Scanner;

public class 打水 {
    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        int n= scan.nextInt();
        int []t=new int[n];
        for (int i = 0; i < n; i++) {
            t[i]= scan.nextInt();
        }
        //排序，谁打水耗时最少就先打水
        Arrays.sort(t);
        long res=0l;
        for (int i = 0; i < n; i++) {
            res+=t[i]*(n-i-1);
        }
        System.out.println(res);
    }
}